[login]
	Login Version 1.1.2 -- Created by Johan Slve johan@solve.se
	New in 1.1.1: added content-type to the authentication header
	New in 1.1.2: doesn't return true or false if "noabort" is used, read
	the variable "macro_login_authenticated" instead.
	
	Displays an http authentication dialog. If the user enters an 
	incorrect username and password, Lasso processing will be aborted
	and a "Not authorized" message will be displayed.
	Use this tag at the beginning of the page to protect. 
	You must specify a username and password in the tag, and you can
	optionally enter an arbitrary prompt string that will be displayed
	in the authentication dialog. If you don't specify a prompt string,
	"Enter login" will be displayed.
	You can also specify "noAbort" as parameter. In that case the macro
	will not abort Lasso processing and will not display a "Not authorized" message.
	Instead the tag will return "true" or "false" in the variable "macro_login_authenticated"
	to indicate if the visitor is authorized.
	Tags modifying the http header (for example cookie and content-type) must
	appear after the login-tag, or it will not work.
	
	The username and password are not case sensitive. 
	Usage examples: 
	a)	[login: username='admin', 
			password='anypassword', 
			prompt='Enter name and password:']
		-- page content
		
	b)	[if: (login: username='admin', 
			password='anypassword', 
			noAbort)!='true']
			Not Authorized
		[else]
			-- page content
		[/if]

#MACRO_BEGIN
[Macro_Parent: #MACRO_INSERT_PARAMS#][Lasso_Comment]

[Variable_Set: 'macro_login_authenticated'='false']

[if: (client_username)!=''&&(client_password)!='']
[if: (client_username, EncodeNone)==(macro_param: 
'username', EncodeNone)&&(client_password, EncodeNone)==(macro_param: 
'password', EncodeNone)]
[Variable_Set: 'macro_login_authenticated'='true']
[/if]
[/if]

[/Lasso_Comment][if: (Variable: 
'macro_login_authenticated')!='true'][header]
HTTP/1.0 401
Content-type: text/html
WWW-Authenticate:Basic Realm="[if: (macro_param: 
'prompt', EncodeNone)!=''][macro_param: 'prompt', EncodeNone][else]Enter login[/if]"
[/header][if: #MACRO_INSERT_PARAM noabort#!='noabort']
<h2>Not authorized</h2>
[Lasso_Abort]
[/if][/if][/Macro_Parent]
#MACRO_END
